<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<base href="<%=basePath%>">
<title>险种列表</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
	<script type="text/javascript">
	var startP = 1;
	$(document).ready(function() {
		//初始读取数据
		loadProductData();
	});
	function queryProduct(displayPage){
		var tradProdCode= $("#tradProdCode").val();
		var tradProdDesc= $("#tradProdDesc").val();
		var status= $("#status").val();
		var startDate= $("#startDate").val();
		var endDate= $("#endDate").val();
		loadProductData({current:displayPage,size:10,tradProdCode:tradProdCode,tradProdDesc:tradProdDesc,status:status,startDate:startDate,endDate:endDate});
	}
	function loadProductData(param){
		 Loading.style.display='block';
		   var jsonDate;
		   
			if(null != param && null != param.current){
				var str = "";
				var strReg = "[0-9]{4}-[0-9]{2}-[0-9]{2}";
				var startDate = param.startDate;
				var endDate = param.endDate;
				if(null != startDate && "" != startDate){
					if(startDate.match(strReg)==null){
						$.message("error", "您输入的定义起期格式不正确，格式为：YYYY-MM-DD");

						return;
					}
				}
				if(null != endDate && "" != endDate){
					if(endDate.match(strReg)==null){
						$.message("error", "您输入的定义止期格式不正确，格式为：YYYY-MM-DD");

						return;
					}
				}
				jsonDate =param;
				
			}else{
				jsonDate={current:1,size:10};
			}
			
			Loading.style.display='block';
			$.ajax({
					url : "product/queryList",
					type : 'POST',
					async : false,
					dataType:'json',
					data:jsonDate,
					success : function(page) {
						Loading.style.display = 'none';
						if($.validate(page))return;
						
							startP = page.current;
							var firstbutton ="<input class='input_fxk' name='radioProduct' type='radio' value='#'>";

							var lastbutton = "<a href='javascript:void(0)' onClick='delChannelInfo(#);return false'>编辑</a>&nbsp;<a href='javascript:void(0)' onClick='delTradProdInst(#);return false'>删除</a>";
							var tableContent = creatTable1("tradProdCode,tradProdDesc,startDate,instant?[{Y:'是'};{N:'否'}],status?[{0:'无效'};{1:'有效'}],<a href='' style='font-size:12px;display: block;overflow: hidden;white-space: nowrap;text-align:center;-o-text-overflow: ellipsis;text-overflow: ellipsis;width:240px;font-family:宋体;font-weight:normal' onDblClick='copyDetail(this);' onclick='showDatail(this);return false' onmouseover='showDatail(this);return false' onmouseout='closeDatail(this);return false'>error_Desc</a>",page,firstbutton,lastbutton);
							
							var tableObj = $("#gatewayproductTable");
							tableObj.find("tbody").remove();
							tableObj.append(tableContent);
							var strPage = creatChannelPage(startP,6,page.maxPage,"7");
							var pageDIV = $("#txproductpageDIV");
							pageDIV[0].innerHTML="";
							
							pageDIV.append(strPage);
					}
				});
		}
	function delTradProdInst(tradProdCode){
		Loading.style.display='block';
		if(!confirm("确定要删除该产品吗？")){ 
			Loading.style.display='none';
			return;
		}
		$.ajax({
				url : "product/delete",
				type : 'POST',
				async : false,
				dataType:'json',
				data:{
					tradProdCode:tradProdCode
				},
				success : function(obj) {
					Loading.style.display = 'none';
					
					if($.validate(obj))return;
					
					queryProduct(1);
				}
			});
	}
	function vreset(){
		$("#tradProdCode").val("");
		$("#tradProdDesc").val("");
		$("#startDate").val("");
		$("#endDate").val("");
		$("#status").val("");
	}
	function add(){
		window.location.href='<%=basePath%>product/add';
	}
	function insuranceAdd(){
		var radioProduct = $("input[name='radioProduct']:checked");
		if(radioProduct.val()!=undefined){
			window.location.href='<%=basePath%>product/prodPlan?tradProdCode='+radioProduct.val();
		}else{
			$.message("error", "请选择一个产品");
		}
		
		
	}
	</script>
	<style>
	.input_fxk {
	width: 15px;
	height: 15px;
	}
	</style>
</head>
<body>
<div class="right">
	<div class="current">
           <table class="current_table_1">
              <tbody><tr class="f2">
                <td><img src="./images/current_1.jpg"></td>
                  <td class="current_table_1_td">
                  <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                  <span style=" color:#136bab; ">产品管理
                  <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>产品配置
                  <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>产品列表
                  </span>
                  </td>
                  <td><img src="./images/current_3.jpg"></td>
              </tr>
           </tbody></table>
      </div>
	<table class="table_02" id="table">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td width="20%" height="30">产品代码:
								<input name="txt3"  id="tradProdCode"  type="text" class="input_text" value="">
							</td>
							<td width="20%" height="30">产品描述:
								<input name="txt3" id="tradProdDesc"  type="text" class="input_text" value="">
							</td>
							<td width="20%" height="30">状态:
								<select  class="search_select_1" id="status" >
									<option value="">--请选择--</option>
									<option value="1">有效</option>
									<option value="0">无效</option>
								</select>
							</td>
							<td width="20%" height="30">定义起期:
								 <input id="startDate"  onkeydown="false"  onclick="showCalendar('startDate','y-mm-dd');"  class="input_time"  type="text" />
							</td>
							<td width="20%" height="30">定义止期:
								 <input id="endDate"  onkeydown="false"  onclick="showCalendar('endDate','y-mm-dd');"  class="input_time"  type="text" />
							</td>
						</tr>
						<tr height="30px">
							<td style="text-align: center;" colspan="5" width="100%" height="30"><input type="button"  class="input_button_1" id="searchBtn" value="查 询" onClick="queryProduct(1)"/>&nbsp;<input type="button"  class="input_button_1" id="searchBtn" value="重置" onClick="vreset()"/></td>
							
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
						<table class="search_table">
							<tr height="30px">
								<td width="100%" height="30">
									 <input type="button"  class="input_button_1" id="searchBtn" value="增加" onClick="add()"/>&nbsp;<input type="button"  class="input_button_2" id="searchBtn" value="险种配置" onClick="insuranceAdd()"/>
								</td>
							</tr>
						</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="gatewayproductTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:10%">交易系统产品代码</th>
			                  <th style="width:50%">交易系统产品描述</th>
			                  <th style="width:10%">定义时间</th>
			                  <th style="width:10%">即时投保限制</th>
			                  <th style="width:5%">状态</th>
			                  <th style="width:10%">操作</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="txproductpageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div id="Loading" style="display:none" align="center">
			<img src="./images/loading.gif" />
		</div>
		<div id="detail" style="display:none;">
			<div id="input" style="margin:5px;word-wrap:break-word"></div>
		</div>
		<div id="detail2" style="display:none;">
			<h4 style="background-color:#A4BDE3;"></h4>
				<table>
					<thead></thead>
					<tr>
					<td width="200px"></td>
					<td align="right"><img src="./images/closedown.gif"  onclick="closeDiv()"/></td>
					</tr>							
				</table>
				<input type="hidden" id="appId" value="">
				
			<div id="output" style="margin:5px;word-wrap:break-word"></div>
		</div>
</div>		
</body>
</html>